package com.fileshare.web.dao.base;

import com.fileshare.web.exception.FsRuntimeException;
import com.fileshare.web.utils.SystemUtil;

import static com.fileshare.web.constant.EntityConstant.SEQ_LEN;

public interface SequenceGenerater<T> {
    default String generateSeq() {
        String sequence = SystemUtil.genSeq(SEQ_LEN);
        while (this.findBySeq(sequence) != null) {
            sequence = SystemUtil.genSeq(SEQ_LEN);
        }
        return sequence;
    }

    default T findBySeq(String seq) {
        throw new FsRuntimeException("not implements findBySeq method");
    }

}
